/* import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'

export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src')
    }
  }
}) */
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import path from 'path';
import { VitePWA } from 'vite-plugin-pwa';

export default defineConfig({
	optimizeDeps: {
		include: ['axios'],
	},
	resolve: {
		alias: { '@': path.resolve(__dirname, './src') },
	},
	plugins: [
		vue(),
		VitePWA({
			registerType: 'autoUpdate',
			includeAssets: [
				'favicon.ico',
				'robots.txt',
				'health-literacy-2025.json', // ← 确保它在 public/ 根目录
			],
			manifest: {
				name: '离线问卷系统',
				short_name: '问卷',
				start_url: '.',
				display: 'standalone',
				background_color: '#ffffff',
				theme_color: '#409EFF',
				icons: [
					{ src: '192.png', sizes: '192x192', type: 'image/png' },
					{ src: '512.png', sizes: '512x512', type: 'image/png' },
				],
			},
			workbox: {
				// 缓存所有 .js .css .html .png .json 文件
				globPatterns: ['**/*.{js,css,html,png,json}'],
			},
		}),
	],
});
